package com.wunong.smart.commission.client.rpc;

import com.wunong.smart.commission.client.param.CancelCommissionParam;
import com.wunong.smart.commission.client.param.CreateCommissionParam;
import com.wunong.smart.commission.client.param.FinishCommissionParam;
import com.wunong.smart.commission.client.service.CommissionWriteService;
import com.wunong.smart.domain.platform.rpc.ResultHandler;
import lombok.Setter;

import javax.annotation.Resource;

/**
 * 代办写服务
 *
 * @author create by zealot.zt
 */
public class CommissionWriteRpcClient {

    @Setter
    @Resource
    protected CommissionWriteService commissionWriteService;

    /**
     * 创建
     *
     * @param param
     * @return
     */
    public Long create(CreateCommissionParam param) {
        final String format = "commission#create, param:%s";

        return ResultHandler.invoke(() -> commissionWriteService.create(param), format, param);
    }

    /**
     * 取消
     *
     * @param param
     * @return
     */
    public Void cancel(CancelCommissionParam param) {
        final String format = "commission#cancel, param:%s";

        return ResultHandler.invoke(() -> commissionWriteService.cancel(param), format, param);
    }

    /**
     * 结束
     *
     * @param param
     * @return
     */
    public Void finish(FinishCommissionParam param) {
        final String format = "commission#finish, param:%s";

        return ResultHandler.invoke(() -> commissionWriteService.finish(param), format, param);
    }

}
